#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
void swap(int* as, int* aq)
{
	int tmp = *as;
	*as = *aq;
	*aq = tmp;
}
void xuanzepaixu(int* a, int n)
{
	int begin = 0;
	int end = n-1;
	while (begin < end)
	{
		int max = begin;
		int min = begin;
		for (int i = begin+1; i <= end; i++)
		{
			if (a[min] > a[i])
			{
				 min = i;
			}
			if (a[max] < a[i])
			{
				 max = i;
			}
		}
		swap(&a[min], &a[begin]);
		if (begin == max)
		{
			max = min;
		}
		swap(&a[max], &a[end]);
		begin++;
		end--;
	}
}
int main()
{
	int arr[] = { 34,56,56,87,7644,79,382,4657,272687,246581,6341,346345,5,267,7,22,2724,57 };
	xuanzepaixu(arr, sizeof(arr) / sizeof(arr[0]));
	for (int i = 0; i < sizeof(arr) / sizeof(0); i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}